/**
 * Created by Administrator on 2015/9/8.
 */
var mysql = require('mysql');
var $conf = require('../../conf/db');
var $util = require('../utils/util');
var $sql = require('../mapping/cusSupermapping');

var pool = mysql.createPool($util.extend({}, $conf.mysql));


module.exports = {
    // 查看与用户有关的活动
    queryActiveByUserInfoId:function(req,userInfoId,param,callback){
        $util.queryHelper(req,$sql.queryActiveAboutMe, [userInfoId,"%"+param+"%"],  pool,function (result) {
            callback(result,param);
        })
    },
    // 查看将要进行的活动
    queryComingActive:function (req,param, callback) {
        $util.queryHelper(req, $sql.queryComingActive, ["%"+param+"%",req.session.currentUser.userInfoId], pool, function (result) {
            callback(result,param);
        })
    },
    changeAdmitStatus:function(req,status,invitedId,callback){
        $util.queryHelper(req,$sql.changeAdmitStatus, [status,invitedId],  pool,function (result) {
                callback(status,invitedId,result);
        })
    },
    cancelApply:function(req,callback){
        $util.queryHelper(req,$sql.cancelApply, req.param('id'),  pool,function (result) {
            callback(result);
        })
    },
    applyActive:function(req,callback){
        $util.queryHelper(req,$sql.applyActive, req.param('id'),  pool,function (result) {
            callback(result);
        })
    },

};